package com.etc.controller;

import com.etc.domain.ZtreeResult;
import com.etc.entity.Product;
import com.etc.entity.ProductCategory;
import com.etc.service.ProductCategoryService;
import com.etc.service.ProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/prod")
public class ProductController {
    //service接口的实例化对象
    @Autowired
    private ProductService ps;

    /**
     * @return ZtreeResult
     */
    @RequestMapping("/findAllProd")
    public List<Product> findAllProCat() {
        List<Product> list = ps.findAllProduct();
        return list;
    }

    @RequestMapping("/deleteThisProd")
    public boolean delectThisProd(Long op){
        boolean flag = ps.delectThisProd(op);
        return flag;
    }

    @RequestMapping("/findAllByPage")
    public PageInfo<Product> findAllByPage(@RequestParam(value = "unm") Integer unm){
        PageInfo<Product> pageInfo = ps.doFindAllByPage(unm);
        return pageInfo;
    }
}
